import {createStore} from 'vuex'
import moduleB from './modules/modulesB'

export default createStore({
    modules:{
        b:moduleB
    },
    state:{
        count:1,
        test:'hello world'
    },
    getters:{
        countAddFive:(state) =>{
            return state.count + 5
        },
        countAddFiveAddTen:(state,getters) =>{
            return getters.countAddFive + 10
        }
    },
    mutations:{
        add(state){
            state.count++
        },
        addPlayload(state,playload){
            state.count += playload.num
        }
    },
    actions:{
        // addAction(context){
        //     context.commit('add')
        // },
        addAction({commit}){
            commit('add')
        },
        asynAddction({commit}){
            setTimeout(()=>{
                 commit('add')
            },1000)
        },
        asyncAddployloadAction({commit},playload){
            setTimeout(()=>{
                commit('addPlayload',playload)
           },1000)
        }
    },
})